#ifndef _NETWORK_INCLUDE_VSOMEIPSERVER_H_
#define _NETWORK_INCLUDE_VSOMEIPSERVER_H_

#include <vsomeip/vsomeip.hpp>
#include <chrono>
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <thread>
#include <mutex>
#include <atomic>
#include <queue>

class VsomeipServer 
{
public:
    VsomeipServer();
    ~VsomeipServer() = default;

    static VsomeipServer& instance();

    void startup();
    void teardown();

private:
    bool init();
    void start();
    void stop();
    void stop_offer();

    void onState(vsomeip::state_type_e _state);
    void run();

    bool onRegisterSubscriptionDMS(vsomeip::client_t, vsomeip::uid_t, vsomeip::gid_t, bool);

    std::shared_ptr<vsomeip::application> itsApp;
    std::atomic<bool> isRunning;
    std::thread notify_thread_;
    std::thread itsVsomeipThread;

    // New DMS Service
    static constexpr auto DMS_SERVICE_ID         = 0x0402;
    static constexpr auto DMS_INSTANCE_ID        = 0x0001;
    static constexpr auto DMS_METHOD_ID          = 0x8001;
    static constexpr auto DMS_H264_IMG_EVENT_ID  = 0x1101;
    static constexpr auto DMS_DETECT_BBOX        = 0x1102;
    static constexpr auto DMS_KEYPOINT           = 0x1103;
    static constexpr auto DMS_EVENTGROUP_ID      = 0x1101;
};


#endif